﻿using Prism.Commands;
using Prism.Services.Dialogs;

namespace MachineVision.Core
{
    public class DialogViewModel : IDialogAware
    {
        public DialogViewModel()
        {
            SaveCommand = new DelegateCommand(Save);
            CancelCommand = new DelegateCommand(Cancel);
        }

        public DelegateCommand SaveCommand { get; set; }
        public DelegateCommand CancelCommand { get; set; }
        public string Title { get; set; }

        public event Action<IDialogResult> RequestClose;

        public bool CanCloseDialog()
        {
            return true;
        }

        protected virtual void Cancel()
        {
            RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
        }

        protected virtual void Save()
        {
            RequestClose.Invoke(new DialogResult(ButtonResult.OK));
        }

        public void OnDialogClosed() { }

        public void OnDialogOpened(IDialogParameters parameters) { }
    }
}
